function maxArea(height) {
  let left = 0;
  let right = height.length - 1;
  let max = 0;

  while (left < right) {
    // 计算当前容器的容量
    const currentArea = Math.min(height[left], height[right]) * (right - left);
    // 更新最大容量
    max = Math.max(max, currentArea);

    // 移动高度较小的指针
    if (height[left] < height[right]) {
      left++;
    } else {
      right--;
    }
  }

  return max;
}
